home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / tcp / HyperMail102.lha / HyperMail / libcgi / template.c < prev   
C/C++ Source or Header  |  1995-06-18  |  1KB  |  56 lines

  1. /*
  2.  * This file is part of the LIBCGI library
  3.  *
  4.  * Copyright 1994 by Enterprise Integration Technologies Corporation
  5.  *
  6.  * This is freeware with commercialization rights reserved; see the
  7.  * LICENSE included in the distribution for specifics.
  8.  */
  9.  
  10. #include<stdio.h>
  11. #include "cgi.h"
  12.  
  13. cgi_main(ci)
  14.      cgi_info *ci;
  15.  {
  16.   char *parmval();
  17.   form_entry *parms, *p;
  18.   form_entry *get_form_entries();
  19.   char *foo, *bar;
  20.  
  21.   print_mimeheader("text/html");
  22.  
  23.   puts("<title>Your Title Here</title>");
  24.   puts("<h1>Your heading here</h1>");
  25.  
  26.   parms = get_form_entries(ci);
  27.   if (parms) {
  28.     /* extract specific form parameters */
  29.     for(p=parms; p; p = p->next) {
  30.       if (strcasecmp(p->name, "foo")) foo = p->val;
  31.       else if (strcasecmp(p->name, "bar")) bar = p->val;
  32.     }
  33.   }
  34.  
  35.   switch(mcode(ci)) {
  36.  
  37.   case MCODE_HEAD:
  38.     return;
  39.  
  40.   case MCODE_GET:    
  41.     puts("Your GET response here");
  42.     printf("based on foo=%s and bar=%s.\n", foo, bar);
  43.     break;
  44.  
  45.   case MCODE_POST:
  46.     puts("Your POST response here");
  47.     printf("based on foo=%s and bar=%s.\n", foo, bar);
  48.     break;
  49.  
  50.   default:
  51.     printf("Unrecognized method '%s'.\n", ci->request_method);
  52.   }
  53.  
  54.   free_form_entries(parms);
  55. }
  56.